home *** CD-ROM | disk | FTP | other *** search
- DECLARE FUNCTION AltKey% ()
-
- DO
- K% = AltKey%
- LOCATE 1, 1
- PRINT TIME$
- LOOP UNTIL K%
-
- IF K% > 255 THEN
- PRINT "Alt was pressed alone"
- ELSEIF K% < 0 THEN
- PRINT "Extended code"; -K%
- ELSE
- PRINT "You pressed the"; K%; "key"
- END IF
-
- FUNCTION AltKey% STATIC
-
- Temp$ = INKEY$ 'see if a "real" key was pressed
- SELECT CASE LEN(Temp$)
- CASE 1 'if it's a regular key then
- AltKey% = ASC(Temp$) ' return its ASCII value
- CASE 2 'if it's an extended key then
- AltKey% = -ASC(RIGHT$(Temp$, 1)) 'negate the extended key code
- AltDown% = 0 'clear the flag that remembers Alt
- CASE ELSE
- AltKey% = 0
- DEF SEG = 0 'examine low memory for the Alt-key
- IF PEEK(&H417) AND 8 THEN 'it's now being pressed
- AltDown% = -1 'remember that Alt is now pressed
- 'AltKey% = 257 'use this to continuously monitor Alt
- ELSEIF AltDown% THEN ' in the calling program
- AltDown% = 0
- AltKey% = 256 'show that Alt alone was pressed
- END IF
- DEF SEG 'restore for later PEEKs and BLOADs
- END SELECT
-
- END FUNCTION